import process from 'process';

/////  -----  实例1  -----
process.on('beforeExit', (code) => {
    console.log('beforeExit code: ', code);
});

process.on('exit', (code) => {
    console.log('exit code: ', code);
});



/////  -----  实例2  -----
process.on('rejectionHandled', (promise) => {
    console.error('rejectionHandled', promise);
    //setImmediate(() => process.exit(1));
});
process.on('multipleResolves', (type, promise, reason) => {
    console.error('multipleResolves', type);
    //setImmediate(() => process.exit(1));
});
async function main() {
    try {
        return await new Promise((resolve, reject) => {
            resolve('multipleResolves First call');
            reject(new Error('Swallowed reject'));
        });
    } catch {
        throw new Error('Failed');
    }
}
main().then(console.log);